﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Crossborder.Core.Migrations
{
    /// <inheritdoc />
    public partial class _25081701update : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ProductSpecs");

            migrationBuilder.CreateTable(
                name: "OrderDetail",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false, comment: "主键Id")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    OrderMasterGuid = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "订单Guid"),
                    OrderDetailGuid = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "订单明细Guid"),
                    ProductId = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "商品Id"),
                    ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "商品名称"),
                    ProductSpec = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "商品规格"),
                    ProductImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "商品图片地址"),
                    ProductNum = table.Column<int>(type: "int", nullable: false, comment: "商品数量"),
                    Price = table.Column<decimal>(type: "decimal(18,3)", precision: 18, scale: 3, nullable: false, comment: "商品价格"),
                    CreateDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "创建时间"),
                    ModifyDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "修改时间"),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false, comment: "是否启用"),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OrderDetail", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProductClassify",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false, comment: "主键Id")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProClassifyId = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "产品分类Id"),
                    ProductId = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "产品Id"),
                    ClassifyName = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "产品分类名称"),
                    Price = table.Column<decimal>(type: "decimal(18,3)", precision: 18, scale: 3, nullable: true, comment: "产品价格（小数点保留后 3位数）"),
                    CreateDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "创建时间"),
                    ModifyDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "修改时间"),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false, comment: "是否启用"),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductClassify", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProductPhotos",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false, comment: "主键Id")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductId = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PhotoId = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Order = table.Column<int>(type: "int", nullable: false),
                    CreateDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "创建时间"),
                    ModifyDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "修改时间"),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false, comment: "是否启用"),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductPhotos", x => x.Id);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OrderDetail");

            migrationBuilder.DropTable(
                name: "ProductClassify");

            migrationBuilder.DropTable(
                name: "ProductPhotos");

            migrationBuilder.CreateTable(
                name: "ProductSpecs",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false, comment: "主键Id")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CreateDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "创建时间"),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false, comment: "是否删除"),
                    IsEnabled = table.Column<bool>(type: "bit", nullable: false, comment: "是否启用"),
                    ModifyDate = table.Column<DateTime>(type: "dateTime2", nullable: false, comment: "修改时间"),
                    Price = table.Column<decimal>(type: "decimal(18,3)", precision: 18, scale: 3, nullable: true, comment: "价格（保留后3位）"),
                    ProSpecsId = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "规格Id"),
                    ProductId = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "产品Id"),
                    SpecsName = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "规格名称"),
                    Unit = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "单位")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductSpecs", x => x.Id);
                });
        }
    }
}
